import React, { useEffect } from "react"
import ErrorBoundary from "@/components/ErrorBoundary"
import { useDispatch } from "react-redux"
import { setRouterData } from "../store/common"

export default function ComponentWrap(props) {
  const { data } = props
  const dispatch = useDispatch()
  useEffect(() => {
    dispatch(setRouterData(data))
  }, [JSON.stringify(data)])

  return <ErrorBoundary>{props.children}</ErrorBoundary>
}
